package com.rs.portal.reserve.web;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;

import com.jaxplat.commons.Row;
import com.rs.commons.web.PortalBaseAction;
import com.rs.rsbiz.reserve.delegate.ReserveDelegate;
import com.rs.rsbiz.reserve.entity.ReserveOrder;
import com.rs.util.Utils;

public class ReserveAction  extends PortalBaseAction{
    private ReserveDelegate reserveDelegate ;

    public ReserveDelegate getReserveDelegate() {
        return reserveDelegate;
    }

    public void setReserveDelegate(ReserveDelegate reserveDelegate) {
        this.reserveDelegate = reserveDelegate;
    }

    /**
     * 我的预约查询
     * 
     * @param request
     * @param response
     * @return
     * @throws Exception
     */
    public ModelAndView searchSecInfo(HttpServletRequest request, HttpServletResponse response) throws Exception
    {
        Row param = this.parseRequestParametersToRow(request);
        ReserveOrder reserveRecord = new ReserveOrder();
        reserveRecord.setOrderId(param.getString("orderId"));
        reserveRecord.setMobileNo(param.getString("mobileNo"));
        Map map = new HashMap();
        Row reserveInfo = this.reserveDelegate.queryReserve(reserveRecord);
        String returnView ="";
        if (null != reserveInfo) {
            String strDate = Utils.myFmtDate(reserveInfo.get("reserve_time").toString());
            map.put("reserveTime", strDate);
            map.put("reserveInfo", reserveInfo); // 这一句相当于request.setAttribute("list",list);
            returnView = "myReserveList"; //结果页面
        } else {
            map.put("message", "没有查到该订单记录,请录入正确的订单号和手机号！"); //返回查询页面
            returnView = "searchMyReserve";
        }
        return new ModelAndView(returnView, map);
    }
}
